package com.centaline.androidsalesblog.rx.database;

import com.centaline.androidsalesblog.constants.AppConstant;
import com.centaline.androidsalesblog.model.databaseobject.BrowseDo;

import rx.Observable;
import rx.Subscriber;

/**
 * Created by guilin on 16/6/1.
 * <p/>
 * 描述:保存浏览id
 */
final class BrowseSaveOnSubscribe implements Observable.OnSubscribe<Void> {

    final int type;
    final String id;

    public BrowseSaveOnSubscribe(int type, String id) {
        this.type = type;
        this.id = id;
    }

    @Override
    public void call(Subscriber<? super Void> subscriber) {
        BrowseDo browseDo = new BrowseDo(AppConstant.CityCode, type, id);
        browseDo.save();
        if (!subscriber.isUnsubscribed()) {
            subscriber.onNext(null);
        }
        subscriber.onCompleted();
    }
}
